package com.lanlian.cayman.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lanlian.cayman.R;
import com.lanlian.commonlib.bean.BankInfo;
import com.lanlian.commonlib.common.SystemConfig;
import com.lanlian.imagelib.ShowImageUtils;

import java.util.List;

/**
 * <pre>
 *     author : huxiaobo
 *     e-mail : huxiaobo@xlanlian.com
 *     date   : 2018/11/6 16:43
 *     desc   : 银行卡适配器
 *     version: 1.0
 * </pre>
 */
public class BankAdapter extends BaseQuickAdapter<BankInfo, BaseViewHolder> {

    public BankAdapter(int layoutResId, @Nullable List<BankInfo> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BankInfo item) {
        helper.setText(R.id.tv_bank_name, item.getBankName())
                .setText(R.id.tv_bank_card, item.getCardNo());
        if (TextUtils.isEmpty(item.getBankType())) {
            helper.setText(R.id.tv_bank_type, "储蓄卡");
        } else {
            helper.setText(R.id.tv_bank_type, item.getBankType());
        }
        helper.setGone(R.id.img_more, getData().size() > 1);
        ShowImageUtils.showImageView(mContext, item.getLogo(), SystemConfig.IMG_DEFAULT_BACKGROUND,
                helper.getView(R.id.img_bank_logo));
        ShowImageUtils.showImageView(mContext, item.getBackground(), SystemConfig.IMG_DEFAULT_BACKGROUND,
                helper.getView(R.id.img_bank_bg));
    }

}
